/*
 * Copyright 2008 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.splink.asbeangen.templates;

public class ClassTemplateHelper {
	public ClassTemplateHelper() {
	}

	public static String firstCharToUpperCase(String str) {
		return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
	}

	public static String firstCharToLowerCase(String str) {
		return str.substring(0, 1).toLowerCase() + str.substring(1, str.length());
	}

	public static String firstCharToLowerCaseArray(String str) {
		if (str.indexOf(".") == -1)
			return str;

		String[] ar = str.split("\\.");
		String s = "";
		for (int i = 0; i < ar.length; i++) {
			s += firstCharToLowerCase(ar[i]);
			if (i < ar.length - 1)
				s += ".";
		}
		return s;
	}

	public static String cleanLastOccurrence(String head, String sign) {
		if (head.indexOf(sign) != -1)
			return head.substring(0, head.lastIndexOf(sign));
		return head;
	}
}
